﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BLL;
using DAL_NhaSach;

namespace BLL_NhaSach
{
    public class PhieuThuTienBLL :IProcessData
    {
        QLNhaSachEntities db;
        public PhieuThuTienBLL(String cnStr)
        {
            db = new QLNhaSachEntities(cnStr);
        }
        public object getAllData()
        {
            return (from pt in db.PhieuThus select new {pt.MaPhieuThu,pt.KhachHang.TenKH,pt.NgayThu,pt.TienThu });
        }

        public object findObjects(string find_content)
        {
            throw new NotImplementedException();
        }

        public object findObjects(int find_content)
        {
            return db.PhieuThus.SingleOrDefault(p => p.MaPhieuThu == find_content);
        }

        public object sort(string Col_Name, bool state)
        {
            throw new NotImplementedException();
        }

        public bool addObject(object addObj)
        {
            PhieuThu pt = (PhieuThu)addObj;
            if (pt != null)
            {
                try
                {
                    db.PhieuThus.AddObject(pt);
                    db.SaveChanges();
                    return true;
                }
                catch (Exception)
                {
                    return false;
                }
            }
            else return false;
        }

        public bool deleteObject(int id)
        {
            throw new NotImplementedException();
        }

        public bool updateObject(object updateObj)
        {
            throw new NotImplementedException();
        }
    }
}
